Skip to content

buildClientSchema: build enum type value maps lazily #4424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2025

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Jun 3, 2025

The option of passing a thunk was made available by: #4018 .

Always passing the thunk helps contribute to a "lazy" build process, which gives the following performance boost:

image

@yaacovCR yaacovCR requested a review from a team as a code owner June 3, 2025 18:07
@yaacovCR yaacovCR force-pushed the build-enum-lazily branch from 31a3c51 to 41c044c Compare June 6, 2025 09:14
This makes definition of enum values lazy similar to how field/input field definition is lazy. It brings a small performance improvement when using enums in large schemas, as the enum values are only defined when they are actually used
@yaacovCR yaacovCR force-pushed the build-enum-lazily branch from 41c044c to 51d617e Compare August 8, 2025 21:19
this PR means that bad enum value names will not be checked unless type.getValues() is called in parallel to how bad field names are not checked unless type.getFields() is called.
@yaacovCR
Copy link
Contributor Author

this change as implemented will result in bad enum value names not being checked unless type.getValues() is called in parallel to how bad field names are not checked unless type.getFields() is called.

relevant to: #4362

@benjie
Copy link
Member

benjie commented Aug 18, 2025

Are they checked by the time validateSchema(schema) completes? If not, that does seem a concern.

@yaacovCR
Copy link
Contributor Author

Yes, they are. The linked issue requests earlier errors on bad names, so relevant there, but validation cannot pass with bad names.

@yaacovCR yaacovCR merged commit 1bb1417 into graphql:next Aug 18, 2025
16 checks passed
@yaacovCR yaacovCR deleted the build-enum-lazily branch August 18, 2025 22:30
@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bug fix 🐞 requires increase of "patch" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants